public class Demo18 {
    //ctrl+alt+m快速抽取方法
    public static void main(String[] args) {
        System.out.println("这是String运行的时间输出:");
        System.out.println(String1());

        System.out.println("这是StringBuilder运行的时间输出:");
        System.out.println(StringBuilder1());

    }
    private  static long String1(){
        long start=System.currentTimeMillis();
        String st="";
        for (int i = 0; i <1000; i++) {
            //System.out.println(st.append(i)==st);
            st=st+String.valueOf(i);
        }
        //System.out.println(st);
        long end=System.currentTimeMillis();
        return end-start;
    }

    private static long StringBuilder1() {
        long start=System.currentTimeMillis();
        StringBuilder st=new StringBuilder();
        for (int i = 0; i <70000; i++) {
            //System.out.println(st.append(i)==st);
            st.append(i);
        }
        //System.out.println(st);
        long end=System.currentTimeMillis();
       return end-start;
    }

}
